<!-- 
此组件初始化时不会自动加载数据，请在mounted中 this.$refs.[].initData()
如果放在dialog里面的吗，请在dialog的open事件中用this.$nextTick进行加载
 -->
<template>
  <div>
    <list
      id-key="id"
      ref="list"
      unit="客户"
      :disabled="disabled"
      :show-query="showQuery"
      show-checkbox
      :query-params="queryParams"
      :expand-query="expandQuery"
      :show-summary="showSummary"
      :page="page"
      :get-page-list-func="api.getNameUniqueValueRepeatList"
    >
      <template #toolbar-left>
        <slot name="toolbar-left"></slot>
      </template>
      <template #toolbar-right>
        <slot name="toolbar-right"></slot>
      </template>
      <template #query>
        <el-form-item
          label="客户唯一值"
          label-width="80px"
        >
          <el-input
            v-model.trim="queryParams.nameUniqueValue"
            placeholder="客户唯一值"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item
          label="排除已删除"
          label-width="80px"
        >
          <el-switch v-model="queryParams.excludeDelete"></el-switch>
        </el-form-item>
        <el-form-item
          label="排除被合并"
          label-width="80px"
        >
          <el-switch v-model="queryParams.excludeMerge"></el-switch>
        </el-form-item>
      </template>
      <template #column>
        <el-table-column
          prop="nameUniqueValue"
          min-width="200"
          label="客户唯一值"
          show-overflow-tooltip
        />
        <el-table-column
          prop="quantity"
          width="100"
          label="重复数量"
          align="center"
          sortable="custom"
        >
          <template #default="{row}">
            <span
              class="c-link"
              @click="openList(row.nameUniqueValue)"
            >{{row.quantity}}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="lastCreationTime"
          width="120"
          label="最近创建时间"
          sortable="custom"
        >
          <template v-slot="{ row }">
            <span>{{ row.lastCreationTime | toShortDatetimeString }}</span>
          </template>
        </el-table-column>
        <!-- slot[column] -->
        <slot name="column"></slot>
        <!--/ slot[column]-->
      </template>
    </list>
    <list-dialog
      ref="listDialog"
      :in-dialog="inDialog"
    />
  </div>
</template>
<script>
import listMixin from "@/mixins/list";
import list from "@/components/common/list";
import api from "@/api/crm/customer";
import listDialog from "./listDialog"
export default {
  mixins: [listMixin],
  components: {
    list,
    listDialog
  },
  props: {},
  data() {
    return {
      //查询条件字段
      queryParams: {
        name: "",
        enName: "",
        zhName: "",
        address: "",
        statuses: [],
        excludeDelete: true,
        excludeMerge: true
      },
      api,
    };
  },
  methods: {
    openList(nameUniqueValue) {
      this.$refs.listDialog.openQuery({nameUniqueValue});
    },
  },
};
</script>